package p.ithorns.framework.web.unwrapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.stereotype.Component;
import p.ithorns.framework.core.model.Result;

/**
 * ResultWrapper的解包器
 *
 * @author R
 * @date 2023-3-1
 */
@Component
public class ResultUnWrapper implements UnWrapper<Result<?>> {
    @Override
    public Object unWrap(Result<?> source) {
        Object data = source.getData();
        if (data instanceof IPage) {
            return ((IPage<?>) data).getRecords();
        }
        // List或bean直接返回
        return data;
    }
}